//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_x_xmarkerplayers.sqf"
#include "x_setup.sqf"

#ifndef __TT__
private ["_ap","_as","_isu"];
{
	_ap = __getMNsVar2(_x);
	_as = _x;
	_isu = GV(_ap,xr_pluncon);
	// TYRGHEN - Added check for parachute and for non marked vehicles (like spawned ones)
	if ((isNil "_isu" || {!_isu}) && {!isNil "_ap"} && {alive _ap} && {isPlayer _ap} && {(vehicle _ap == _ap) || {(vehicle _ap) isKindOf "ParachuteBase" } || {!((vehicle _ap) in GVAR(marker_vecs))} }) then {
		_as setMarkerAlphaLocal 1;
		_as setMarkerPosLocal (visiblePositionASL _ap);
		_as setMarkerTextLocal (switch (GVAR(show_player_marker)) do {
			case 1: {name _ap};
			case 2: {""};
			case 3: {GVAR(mark_loc280) + str(9 - round(9 * damage _ap))};
			default {""};
		});
		if (GVAR(p_marker_dirs)) then {_as setMarkerDirLocal (direction (vehicle _ap))};
	} else {
		_as setMarkerPosLocal [0,0];
		_as setMarkerTextLocal "";
		_as setMarkerAlphaLocal 0;
	};
} forEach GVAR(player_entities);
#else
private ["_ap","_as","_isu"];
{
	_ap = __getMNsVar2(_x);
	_as = _x;
	_isu = GV(_ap,xr_pluncon);
	if ((isNil "_isu" || {!_isu}) && {!isNil "_ap"} && {alive _ap} && {isPlayer _ap} && {vehicle _ap == _ap}) then {
		_as setMarkerAlphaLocal 1;
		_as setMarkerPosLocal (visiblePositionASL _ap);
		_as setMarkerTextLocal  (switch (GVAR(show_player_marker)) do {
			case 1: {name _ap};
			case 2: {""};
			case 3: {GVAR(mark_loc280) + str(9 - round(9 * damage _ap))};
			default {""};
		});
		if (GVAR(p_marker_dirs)) then {_as setMarkerDirLocal (direction (vehicle _ap))};
	} else {
		_as setMarkerPosLocal [0,0];
		_as setMarkerTextLocal "";
		_as setMarkerAlphaLocal 0;
	};
} forEach GVAR(entities_tt);
#endif